export function getCookie(key) {
    if (typeof key === 'string') {
        const cookie = document.cookie
        const cookieList = cookie.split('; ')
        let value = undefined
        cookieList.forEach((cookie) => {
            if (cookie.split('=')[0] === key) {
                value = cookie.split('=')[1]
            }
        })
        return value
    } else {
        console.error('getCookie：只接受字符串')
        return undefined
    }
}

export function setCookie(cKey, cValue, exDays) {
    const date = new Date()
    date.setDate(date.getDate + exDays)
    document.cookie = `${cKey}=${cValue}; expires=${date.toUTCString()}`
}

export function removeCookie(key) {
    setCookie(key, '', -1)
}
